using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using View;
using ZWFrameWork;

public class AndroidManager : MonoBehaviour
{
    private AndroidJavaObject mAndroidJavaObject;
    private Action mSeeAdvCompleteCallback;

    private static AndroidManager ins;
    public static AndroidManager Ins
    {
        get { return ins; }
    }

    private void Awake()
    {
        ins = this;
        DontDestroyOnLoad(this);
    }

    public void OnInitSDK()
    {
        if (mAndroidJavaObject == null)
        {
            Debug.LogError("���÷���===================��ѯ����״̬��ʼ��2222222222222");
            // AndroidJavaClass androidclass = new AndroidJavaClass("com.unity3d.player.UnityPlayerActivity");
            // mAndroidJavaObject = androidclass.GetStatic<AndroidJavaObject>("currentActivity");
            mAndroidJavaObject = new AndroidJavaObject("com.unity3d.player.UnityPlayerActivity");//("com.zzsy.xgtk.UnityPlayerActivity");
            Debug.LogError("���÷���===================��ѯ������ʼ��2222222222222===============���");
        }
        // _appInfoTool.Call(Init);
    }
    
    
    public void LoadReward(Action ac = null)
    {
        mSeeAdvCompleteCallback = ac;
// #if UNITY_EDITOR
//         if (ac != null)
//         {
//             ac();
//         }
// #else
//         
//         Debug.LogError("获取广告sdk");
//         ExampleRewardAd.LoadReward();
//         Debug.LogError("获取广告222222sdk");
//         SeeAdvCompleteCallback = ac;
//         
// #endif

        Debug.LogError("加载reward广告");
        mAndroidJavaObject.Call("LoadReward");
    }

    public void LoadBanner(Action ac = null)
    {
        mSeeAdvCompleteCallback = ac;
// #if UNITY_EDITOR
//         if (ac != null)
//         {
//             ac();
//         }
// #else
// Debug.LogError("加载banner广告i");
//         // ExampleBannerAd.LoadNativeBannerAd();
//         ExampleExpressBannerAd.LoadExpressBannerAd();
// #endif
        Debug.LogError("加载banner广告");
        mAndroidJavaObject.Call("LoadBanner");
    }

    //看完广告的回调
    public void OnAdvEndCallBack(string callbackstr)
    {
        Debug.LogError("回调的string："+callbackstr);
        if (mSeeAdvCompleteCallback!=null)
        {
            mSeeAdvCompleteCallback();
        }

        mSeeAdvCompleteCallback = null;
    }
}
